#ifndef _TYPE_TEST_MODULE_H
#define _TYPE_TEST_MODULE_H

#include <fstream>
#include <string>
#include <string.h>
#include <iostream>
#include <time.h>
#include <stdint.h>

typedef struct {
    int totalScore;
    float accuracyRate;
    float costTime;
} TypeTestResult_t;

#define TEST_BUFF_LENGTH    (256)
#define TEST_TIME_LIMIT     (30)

class TypeTestModule
{
private:
    std::ifstream m_fileObj;
    uint32_t m_totalCnt;
    uint32_t m_correctCnt;
    time_t m_costTime;
    char m_testContent[TEST_BUFF_LENGTH];
    char m_inputContent[TEST_BUFF_LENGTH];

private:
    int _openTestContentFile(void);
    int _getLineTestContent(void);
    void _recordResult(void);
    void _echoTestContent(void);
    void _recvInputContent(void);
    void _calculateScore(TypeTestResult_t &result);

public:
    TypeTestModule();
    ~TypeTestModule();
    int initial(const char* path);
    void startTypeTest(TypeTestResult_t &result);
};


#endif